package org.log;

import org.common.DateUtil;

public class ProjectLog {

	/**
	 * @author zhaochang
	 * @param tomcatid  当前tomcatid没有即为空
	 * @param message   要放入的消息
	 */
	public void info(String tomcatid,String message){
		StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
		StringBuffer sb = new StringBuffer();
		if (null!=tomcatid && !"".equals(tomcatid.trim())){
			sb.append("Tomcat ");
			sb.append(tomcatid);
			sb.append(" ");
		}		
		sb.append("[info] ");
		sb.append("[");
		sb.append(DateUtil.getDateTimeByString(DateUtil.getDateTime(),"yyyy-MM-dd HH：mm：ss：ffff"));
		sb.append("] ");
		sb.append(stacks[1].getClassName());
		sb.append(".");
		sb.append(stacks[1].getMethodName());
		sb.append(" line:");
		sb.append(stacks[1].getLineNumber());
		sb.append(" :");
		sb.append(message);
	}
	
	/**
	 * @author zhaochang
	 * @param tomcatid  当前tomcatid没有即为空
	 * @param message   要放入的消息
	 */
	public void error(String tomcatid,String message){
		StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
		StringBuffer sb = new StringBuffer();
		if (null!=tomcatid && !"".equals(tomcatid.trim())){
			sb.append("Tomcat ");
			sb.append(tomcatid);
			sb.append(" ");
		}
		sb.append("[error] ");
		sb.append("[");
		sb.append(DateUtil.getDateTimeByString(DateUtil.getDateTime(),"yyyy-MM-dd HH：mm：ss：ffff"));
		sb.append("] ");
		sb.append(stacks[1].getClassName());
		sb.append(".");
		sb.append(stacks[1].getMethodName());
		sb.append(" line:");
		sb.append(stacks[1].getLineNumber());
		sb.append(" :");
		sb.append(message);
	}

}
